home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / broom / code.lua next >
Text File  |  2005-07-16  |  4KB  |  115 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky01.ogg")
  8.     local pokus = getRestartCount()
  9.     local roompole = createArray(1)
  10.  
  11.  
  12.     -- -------------------------------------------------------------
  13.     local function prog_init_room()
  14.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  15.  
  16.         room.uvod = 0
  17.         room.namet = 0
  18.  
  19.         return function()
  20.             if metla.X == 12 and (metla.Y == 12 or metla.Y == 13 or metla.Y == 14) and not isReady(big) and not small:isOut() then
  21.                 roompole[0] = 1
  22.             end
  23.             if isReady(small) and isReady(big) and no_dialog() then
  24.                 if room.uvod == 0 then
  25.                     addm(random(40) + 10, "kos-m-uklid" ..random(3))
  26.                     addv(random(20), "kos-v-poradek"..random(3))
  27.                     room.uvod = random(150) + 50
  28.                 elseif room.uvod == 2 then
  29.                     room.uvod = 1
  30.                     switch(roompole[0]){
  31.                         [0] = function()
  32.                             pom1 = random(2)
  33.                         end,
  34.                         [1] = function()
  35.                             pom1 = 2
  36.                             roompole[0] = roompole[0] + 1
  37.                         end,
  38.                         [2] = function()
  39.                             pom1 = random(5)
  40.                         end,
  41.                     }
  42.                     if pom1 < 3 then
  43.                         addv(0, "kos-v-koste"..pom1)
  44.                     end
  45.                 elseif room.namet == 0 and random(100) < 3 and metla.Y >= 15 then
  46.                     room.namet = 1
  47.                     pom1 = random(3)
  48.                     if pom1 > 0 then
  49.                         pom1 = pom1 + 1
  50.                     end
  51.                     addm(40, "kos-m-zamet"..pom1)
  52.                     if random(100) < 70 then
  53.                         addm(random(20) + 10, "kos-m-zamet1")
  54.                     end
  55.                 end
  56.             end
  57.         end
  58.     end
  59.  
  60.     -- -------------------------------------------------------------
  61.     local function prog_init_metla()
  62.         return function()
  63.             if odd(game_getCycles()) then
  64.                 switch(metla.afaze){
  65.                     [0] = function()
  66.                         if metla.dir == dir_left or metla.dir == dir_right then
  67.                             metla.afaze = 2
  68.                         end
  69.                     end,
  70.                     [1] = function()
  71.                         if metla.dir == dir_left or metla.dir == dir_right then
  72.                             metla.afaze = 3 - metla.afaze
  73.                         else
  74.                             metla.afaze = 0
  75.                         end
  76.                     end,
  77.                     [2] = function() 
  78.                         if metla.dir == dir_left or metla.dir == dir_right then
  79.                             metla.afaze = 3 - metla.afaze
  80.                         else
  81.                             metla.afaze = 0
  82.                         end
  83.                     end,
  84.                 }
  85.             end
  86.             metla:updateAnim()
  87.         end
  88.     end
  89.  
  90.     -- --------------------
  91.     local update_table = {}
  92.     local subinit
  93.     subinit = prog_init_room()
  94.     if subinit then
  95.         table.insert(update_table, subinit)
  96.     end
  97.     subinit = prog_init_metla()
  98.     if subinit then
  99.         table.insert(update_table, subinit)
  100.     end
  101.     return update_table
  102. end
  103. local update_table = prog_init()
  104.  
  105.  
  106. -- -----------------------------------------------------------------
  107. -- Update
  108. -- -----------------------------------------------------------------
  109. function prog_update()
  110.     for key, subupdate in pairs(update_table) do
  111.         subupdate()
  112.     end
  113. end
  114.  
  115.